package com.hpu.parser;

import com.hpu.bean.EmptyRoom;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class EmptyRoomParser {

	public EmptyRoom parse(String parseString) {
		String room1 = null;
		String room2 = null;
		String room3 = null;
		String room4 = null;
		String room5 = null;

		try {
			JSONObject object=new JSONObject(parseString);
			for(int i=1;i<6;i++){
				JSONArray array=object.getJSONArray(i+"");
				String tmp="";
				for(int j=0;j<array.length();j++){
					tmp+=array.getString(j)+"、";
				}
				if(i==1&&!tmp.equals("")) room1=tmp;
				if(i==2&&!tmp.equals("")) room2=tmp;
				if(i==3&&!tmp.equals("")) room3=tmp;
				if(i==4&&!tmp.equals("")) room4=tmp;
				if(i==5&&!tmp.equals("")) room5=tmp;
			}
			
		} catch (JSONException e) {
			e.printStackTrace();
		}

		return new EmptyRoom(room1, room2, room3, room4, room5);
	}

}
